package reign.engine.structures;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

import reign.engine.exceptions.CardPropertyNotFoundException;
import reign.engine.structures.Card.cardType;

public class Card {

	private String name;
	private int id;
	private cardType type;
	private Properties props;
	private String imageLocation;
	public enum cardType{
		CREATURE,
		STRUCTURE,
		SPELL,
		ABILITY,
		SPECIAL,
		ELITECREATURE,
		RESOURCE;
	};
	
	public Card(String Name, int ID, String description, cardType valueOf,int toughness, int strength, String imageDir) 
	{
		name = Name;
		id = ID;
		type = valueOf;
		imageLocation = imageDir;
		props = new Properties();
		setProperty("Toughness",toughness);
		setProperty("Strength",strength);
	}

	public String getName()
	{
		return name;
	}
	
	public int getID()
	{
		return id;
	}
	
	public cardType getType()
	{
		return type;
	}

	public void setProperty(String name,Object value) {
		props.put(name,value);
	}

	public String getProps(String name) throws CardPropertyNotFoundException {
		String property = props.getProperty(name);
		if(property != null)
		{
			return property;
		}
		throw new CardPropertyNotFoundException(this,name,props);
	}
	
	public String toString()
	{
		return "Name: " + name + " ID: " + id + " Type: " + type.toString() + "\nProperties:\n\t" + propertiesToString();
	}
	
	public String propertiesToString()
	{
		String propData = "";
		Iterator<Entry<Object, Object>> tempData = props.entrySet().iterator();
		while(tempData.hasNext())
		{
			Entry<Object, Object> tempEntry = tempData.next();
			propData += tempEntry.getKey().toString() + ":" + tempEntry.getValue().toString() + "\n\t";
		}
		return propData;
	}
	
}
